﻿package 
{
	import flash.display.*;
	import flash.geom.Matrix;
	import flash.events.*;

	class CoverMc extends MovieClip
	{
		private var imgWidth:int=360;
		private var imgHeight:int=250;
		private var spaceRef:int=2;
		private var gradHeight:int=70;
		public var img:MC;
		public function CoverMc():void
		{
			init();
		}
		private function init():void
		{
			img=new MC()
			var ref:MC=new MC()
			var grad:Shape=drawGrad()
			ref.scaleY=-1;
			ref.y=imgHeight + spaceRef + imgHeight;
			grad.y=imgHeight + spaceRef
			ref.cacheAsBitmap=true;
			grad.cacheAsBitmap=true;
			ref.mask=grad
			this.addChild(img);
			this.addChild(ref);
			this.addChild(grad);
			//this.addEventListener(MouseEvent.CLICK,fnClick)
			//this.addEventListener(MouseEvent.ROLL_OVER,fnOver)
		}		
		private function fnOver(e:Event):void
		{
			trace(this)
			this.gotoAndPlay(2)
		}
		private function fnClick(e:Event):void
		{
			trace(e.target)
		}
		private function drawGrad():Shape
		{
			var type:String=GradientType.LINEAR;
			var colors:Array=[0x00FF00,0x00FF00];
			var alphas:Array=[0.5,0];
			var ratios:Array=[0,255];
			var spreadMethod:String=SpreadMethod.PAD;
			var interp:String=InterpolationMethod.LINEAR_RGB;
			var focalPtRatio:Number=0;

			var matrix:Matrix=new Matrix;
			var boxWidth:Number=100;
			var boxHeight:Number=gradHeight;
			var boxRotation:Number=Math.PI / 2;// 90˚
			var tx:Number=0;
			var ty:Number=-20;
			matrix.createGradientBox(boxWidth,boxHeight,boxRotation,tx,ty);

			var square:Shape=new Shape;
			square.graphics.beginGradientFill(type,colors,alphas,ratios,matrix);
			square.graphics.drawRect(0,0,imgWidth,gradHeight);

			return square;

		}
	}
}